<!--content-->
<div class="bh-content">
	<div class="bh-ly-jj-lyorder_con bh-padT10">
	<?php echo $this->renderPartial('application.views.partials.order.schedule');?>
	<div class='ho-w'>
		<h1>填写订单</h1>
		<div class='ho-inner'>
			<!-- part left -->
			<div class='ho-g-info-w'>
				<div class='ho-g-info-item ho-g-desc-w'>
					<div class='ho-g-img-w imgbox'>
						<a target='<?php echo Yii::app()->option->get('hotel_view_target')?>' href="<?php echo CHtml::value($model, 'items.goods.profile.hotel.vurl')?>" title='<?php echo CHtml::value($model, 'items.goods.profile.hotel.fullTitle')?>'><?php echo $model->items->goods->profile->hotel->img(100,75)?></a>
					</div>
					<div class='ho-g-desc'>
						<a target='<?php echo Yii::app()->option->get('hotel_view_target')?>' class='a-blue' href='<?php echo CHtml::value($model, 'items.goods.profile.hotel.vurl')?>'><?php echo CHtml::value($model, 'items.goods.profile.hotel.fullTitle')?></a>
						<p class='fc-666'><?php echo CHtml::value($model, 'items.goods.profile.hotel.detailProvince').' '.CHtml::value($model, 'items.goods.profile.hotel.address')?></p>
					</div>
					<div class='bh-clear'></div>
				</div>
				<div class='ho-g-info-item ho-g-field-w'>
					<table class='goods-info-tb'>
						<tr><th width=50px>房　型：</th><td><?php echo CHtml::value($model, 'items.goods.profile.room_type')?></td></tr>
						<tr><th>床　型：</th><td><?php echo Yii::app()->enum->lookup('goods.bedType',CHtml::value($model, 'items.goods.profile.bed_type'));?></td></tr>
						<tr><th>早　餐：</th><td><?php echo CHtml::value($model, 'items.goods.profile.breakfast')?></td></tr>
						<tr><th>宽　带：</th><td><?php echo Yii::app()->enum->lookup('goods.broadbandType',CHtml::value($model, 'items.goods.profile.broadband_type'))?></td></tr>
					</table>
				</div>
				<div class='ho-g-info-item ho-g-tip-w last' style='display:none'>
					<ul class='ho-g-tips'>
						<li>7×24小时客户关怀</li>
						<li>超3万家酒店,覆盖全国主要省市</li>
						<li>承诺网络预订最低价</li>
						<li>到店无房赔付首晚房费</li>
						<li>百万真实酒店点评帮您选择心仪酒店</li>
						<li>商务部电商示范企业,服务有保障</li>
					</ul>
				</div>
			</div>
			<!-- end part left -->
			
			<!-- part body -->
			<div class='ho-form-w'>
				<?php $form = $this->beginWidget('lib.widgets.CActiveFormAdv')?>
				<?php echo $form->hiddenField($model,'items.related_id')?>
			    <?php echo $form->hiddenField($model,'items.goods_id',array('id'=>'goodsId'))?>
			    <?php echo $form->hiddenField($model,'items.provider_id')?>
			    <?php echo $form->hiddenField($model,'items.dealer_id')?>
			    <?php echo $form->hiddenField($model,'items.item_price',array('id'=>'price'))?>
				<div class='fieldset'>
					<div class='fieldset-title'><h2><span>酒店价格信息</span></h2></div>
					<div class='fieldset-content'>
						<table class='form-tb largespacing' width=100%>
							<tr><th width=80>预订须知：</th><td><?php echo CHtml::value($model, 'items.goods.profile.notes')?></td></tr>
							<tr><th width=80>房间信息：</th><td><?php echo CHtml::value($model, 'items.goods.profile.info')?></td></tr>
							<tr><th width=80><span class='required'>*</span>预订房型：</th><td class='bh-strong'><?php echo CHtml::value($model, 'items.goods.profile.room_type')?></td></tr>
							<tr>
								<th><span class='required'>*</span>入住日期：</th>
								<td>
									<?php $this->widget('coms.ui.DataPicker', array(
							 			'model' => $model,
							 			'attribute' => 'addon.arrive_time',
										'options' => array(
											'minDate'=>'%y-%M-%d',
										),
										'htmlOptions' => array(
											'id' => 'arrive-time',
											'value' => date('Y-m-d')
										)
									));?>
									<?php echo $form->error($model, 'addon.arrive_time')?>
								</td>
							</tr>
							<tr>
								<th><span class='required'>*</span>退房日期：</th>
								<td>
									<?php $this->widget('coms.ui.DataPicker', array(
							 			'model' => $model,
							 			'attribute' => 'addon.leave_time',
										'htmlOptions' => array(
											'id' => 'leave-time',
											'value' => date('Y-m-d',strtotime('+1day'))
										)
									));?>
									<?php echo $form->error($model, 'addon.leave_time')?>
								</td>
							</tr>
							<tr>
								<th><span class='required'>*</span>房间数量：</th>
								<td>
									<?php echo $form->dropDownList($model, 'items.item_num', Yii::app()->enum->options('num',false),array('id' => 'item-num'))?> 间
									<?php echo $form->error($model, 'items.item_num');?>
								</td>
							</tr>
							<tr class='cell-borderb'>
								<th></th>
								<td id='hotel-content'></td>
							</tr>
							<tr>
								<th class='bh-strong-ipt bh-font14'>房费：</th>
								<td class='font-clr bh-font24 bh-strong'><span class='bh-font12'>¥</span><label id='money'><?php echo CHtml::value($model, 'items.item_price')?></label></td>
							</tr>
						</table>
					</div>
				</div>
				
				<div class='fieldset'>
					<div class='fieldset-title'><h2><span>入住人与订单联系人信息</span></h2></div>
					<div class='fieldset-content'>
						<table class='form-tb largespacing' width=100%>
							<tr width=120>
								<th><?php echo $form->labelEx($model,'pay_type')?>：</th>
								<td> <?php echo $form->dropDownList($model, 'pay_type',Yii::app()->enum->options('order.payType'))?>
									<?php echo $form->error($model, 'pay_type');?>
								</td>
							</tr>
							<tr id='copy-content'>
								<th width=120><span class='required'>*</span>第1位入住人姓名：</th>
								<td>
									<?php echo $form->textField($model,'travelers.0.name')?>
									<?php echo $form->error($model, 'travelers.0.name')?>
								</td>
							</tr>
							<tr>
								<th><span class='required'>*</span>订单联系人姓名：</th>
								<td>
									<?php echo $form->textField($model,'receiverInfo.receiver')?>
									<?php echo $form->error($model, 'receiverInfo.receiver')?>
								</td>
							</tr>
							<tr>
								<th><span class='required'>*</span>订单联系人手机：</th>
								<td>
									<?php echo $form->textField($model,'receiverInfo.mobile')?>
									<?php echo $form->error($model, 'receiverInfo.mobile')?>
								</td>
						</tr>
						</table>
					</div>
				</div>
				
				<div align=center><input class="bh-lr-btn" type="submit" value="提交订单" name="yt0"></div>
			  <?php $this->endWidget()?>
			</div>
			<!-- part body end -->
			
			<div class='bh-clear'></div>
		</div>
	</div>
	
    </div>
</div>
<table style='display:none'>
	<tr id='copy' >
		<th><span class='required'>*</span>第{num}位入住人姓名：</th>
		<td>
			<?php echo $form->textField($model,'travelers.{attrId}.name')?>
			<?php echo $form->error($model, 'travelers.{attrId}.name')?>
		</td>
	</tr>
</table>
<!--content-->

<script>
var oldV1,oldV2;requesting = false;
setTimeout("autoGetMsg()",1000);
$('#item-num').change(function() {
	$('.copy-input').remove();
	html = '';
	for(i=0; i<$(this).val()-1; i++) {
		$ele = $('#copy').clone();
		id = 'N-'+new Date().getTime()+Math.floor(Math.random()*10000);
		html += '  <tr height="40" class="copy-input">'+$ele.html().replace(/{attrId}/g, id).replace(/{num}/,i+2)+'</tr>';
	}
	$('#copy-content').after(html);
	getHotelMsg();
});
$('#leave-time').blur(function() {
	getHotelMsg();
});
$('#arrive-time').blur(function() {
	getHotelMsg();
});

function countMoney() {
	var money = 0;
	$('.hotel-price').each(function() {
		money += myPriceNum($(this).attr('price'))*$('#item-num').val();
	});
	$('#money').html(myPriceNum(String(money)));
}
function getHotelMsg() {
	$('#money').html('<?php echo CHtml::image(Yii::app()->baseUrl.'/images/loading.gif')?>');
	var xhr = null;
	requesting = true;
	if(xhr) xhr.abort();
	xhr = $.get('<?php echo Yii::app()->createUrl('ajaxGet/hotelMsg')?>',{'arriveTime':$('#arrive-time').val(),'leaveTime':$('#leave-time').val(),'id':$('#goodsId').val(),'num':$('#item-num').val()}, function(content) {
		$('#hotel-content').html(content);
		countMoney();
		requesting = false;
	});
}
function autoGetMsg() {
	if(oldV1 != $('#arrive-time').val() || oldV2 != $('#leave-time').val()) {
		oldV1 = $('#arrive-time').val();
		oldV2 = $('#leave-time').val()
		if(!requesting) {
			getHotelMsg();
		}
	}
	setTimeout("autoGetMsg()",1000);
}
</script>